﻿@namespace BootstrapBlazor.Components
@inherits BootstrapComponentBase

<div @attributes="@AdditionalAttributes" class="@ClassString" data-field="@FieldKey" @ref="@FilterElement">
    <div class="card-arrow"></div>
    <div class="card-header"><span>@Title</span></div>
    <div class="card-body">
        @if (Column != null)
        {
            @if (Column.FilterTemplate != null)
            {
                @Column.FilterTemplate;
            }
            else
            {
                <CascadingValue Value="this" IsFixed="true">
                    @{
                        var fieldType = Nullable.GetUnderlyingType(Column.FieldType) ?? Column.FieldType;
                        switch (fieldType?.Name)
                        {
                            case nameof(Boolean):
                                <BoolFilter />
                                break;
                            case nameof(DateTime):
                                <DateTimeFilter Count="@Count" />
                                break;
                            case nameof(Int32):
                            case nameof(Double):
                            case nameof(Decimal):
                                <NumberFilter Count="@Count" />
                                break;
                            case nameof(String):
                                <StringFilter Count="@Count" />
                                break;
                            default:
                                <div>不支持的类型</div>
                                break;
                        };
                    }
                </CascadingValue>
            }
        }
    </div>
    <div class="card-footer">
        <div class="d-flex flex-fill">
            @if (ShowMoreButton)
            {
                <Button Color="@Color.None" OnClick="@OnClickPlus" Icon="fa fa-fw fa-plus" IsDisabled="@(Count == 1)"></Button>
                <Button Color="@Color.None" OnClick="@OnClickMinus" Icon="fa fa-fw fa-minus" IsDisabled="@(Count == 0)"></Button>
            }
        </div>
        <Button Color="@Color.None" class="is-close" OnClick="@OnClickReset" Text="重置"></Button>
        <Button Color="@Color.None" class="is-close" OnClick="@OnClickConfirm" Text="确认"></Button>
    </div>
</div>